package com.usian.common.exception;

import com.usian.model.common.dtos.ResponseResult;
import com.usian.model.common.enums.AppHttpCodeEnum;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
@Log4j2
public class ExceptionCatch {
    //捕获Exception异常
     @ExceptionHandler(Exception.class)
     @ResponseBody
    public ResponseResult  exception(Exception excption){
         excption.printStackTrace();
         //记录日志
         log.error("catch exception:{}",excption.getMessage());
         //返回通用异常
         return ResponseResult.errorResult(500,"二大娘漆梦瑶炖完菜给你解决！！！");
    }
}
